document.documentElement.style.fontSize = innerWidth/16 + 'px';
		window.onresize = function(){
		document.documentElement.style.fontSize = innerWidth/16 + 'px';
	}
		angular.module('myapp2',[]).controller('airCon',['$scope','$http',function($scope,$http){
			//返回上一页面
			$(".fanhui").click(function(){
				window.history.go(-1);
				window.location.reload();
			})
			//获取页面数据
			$scope.air =[];
			$http({
				url:'http://127.0.0.1:4000/store1',
				method:'get'
			}).success(function(data){				
				$scope.air = data.data.hot_goods;
		
				angular.forEach($scope.air,function(value,index){
					
					console.log(value.status);
					var price = value.status;
				})
			});
				//销量从高到低
				$(".rank>p:nth-child(2)").click(function(){
					var jiage = $scope.air.sort(compare('price'));
					$scope.air = jiage;
					$scope.$apply();
				})
				//价格从高到低
				$(".rank>p:nth-child(3)").click(function(){
				console.log(1)
				var rankingList = $scope.air.sort(compare('price'));
				$scope.air = rankingList;
				$scope.$apply();
				console.log($scope.air);					
			})
			function compare(property){
				return function(a,b){
				    var value1 = a[property];
				    var value2 = b[property];
				    return value1 +  value2;
				}
			}
		//点击导航进入蒙版,table切换
		$('.nav p').each(function(){
			var num =0;
			var index = $(this).index();
			$(this).click(function(){
				num++;
				$(this).addClass("color").siblings().removeClass("color");
				$(".table>div").eq(index).stop(true).show().siblings().stop(true).hide();
				console.log($(".table>div").eq(index));
				if(num%2==1){
//					$(".nav p").eq(index).css({"color":"black"});
					$(".nav p").eq(index).find("span").eq(1).attr('class','glyphicon glyphicon-triangle-top');
					$(".table>div").eq(index).show();					
				}else{
//					$(".nav p").eq(index).css({"color":"black"});
					$(".nav p").eq(index).find("span").eq(1).attr('class','glyphicon glyphicon-triangle-bottom');
					$(".table>div").eq(index).hide();
				}
			})
			
		})
			//获取全部目的地数据
			$scope.all=[];			
			$http({
				url:'http://127.0.0.1:4000/all',
				method:'get'
			}).success(function(data){
				$scope.data1 =data.data;
				angular.forEach($scope.data1,function(value,index){
					$scope.all.push(value)
				})
				//点击洲名换国家的数据，变色
				$scope.first = $scope.data1[0].cnname;
				$scope.continent = $scope.data1[0].hot_country;
				$scope.btn = function(index){
					$scope.num = index;
					$scope.first = $scope.data1[index].cnname;
					$scope.continent = $scope.data1[index].hot_country;
				}
				$scope.bse = function(data){
					return $scope.num == data?'green':" ";
				}
			})
			//智能排序
			$(".sold").click(function(){
				$(".rank>:first").attr("class","color");
						
			})	
			$(".rank>p").click(function(){
				$(".rank").toggle();
				$(this).addClass("color").siblings().removeClass("color");
				
				$(".sold").html($(this).html());
			})
			//更多筛选
			$(".more").click(function(){
				$(".shai .one").addClass("background");
			})
			$(".xuan li").click(function(){
				
				$(this).addClass("background").siblings().removeClass("background");
			})
			//重置
			$(".enter").click(function(){
				$(this).addClass("background").siblings().removeClass("background");			
			})
			$(".enter:nth-child(2)").click(function(){
				window.location.href ="air.html";
			})
			$(".enter:nth-child(1)").click(function(){
				location.reload();       
			})
		}])